<?php
namespace App\Http\Controllers\Admin;
use App\Http\Controllers\BaseController;
use App\Models\Focus;
use Illuminate\Http\Request;

class FocusController extends BaseController
{

    public $model = Focus::class;

    public function index(Request $request) {
        $search = ['start_at' => '', 'end_at' => '', 'user_id' => '', 'fans.nickname' => ''];
        $input = $request->input();

        $user_field = ['nickname', 'avatar_url'];
        $list = Focus::apply($search, $input)
            ->withCertain('fans', $user_field)
            ->withCertain('focus', $user_field)
            ->orderBy("id", "desc");
        $list = $list->paginate(per_page());
        return $this->paginate($list);
    }

}

